package com.yc.project3_bestMatching;

import java.io.File;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class TestMain {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        String path= System.getProperty( "user.home") ;
        path = path+ File.separator+"projects_sources"+File.separator+"project3_bestMatching"+File.separator+"UK Advanced Cryptics Dictionary.txt";
        System.out.println(path);
        WordsLoader.load(path);
        List<String> list= WordsLoader.load( path );
//        System.out.println(list.size());

        String word = "sitter";
        BestMatchingTask task = new BestMatchingTask(list,word,0,list.size());
        FutureTask<BestMatchingData> futureTask = new FutureTask<>(task);
        Thread t =new Thread(futureTask);
        t.start();
        BestMatchingData bestMatchingData =futureTask.get();////阻塞式方法，只有任务运行完了，才可以得到结果，程序继续向下。
        System.out.println( bestMatchingData.getDistance()+"   "+bestMatchingData.getWords());



    }
}
